package edu.sctu.practice.class01.wulixia.month09_wlx.assign03.two;

/**
 * Created by wulixia on 2015/11/4.
 * 创建类ComparableCylinder，该类为Cylinder类的子类，并实现Comparable接口。
 */
public class ComparableCylinder extends Cylinder implements Comparable {

    ComparableCylinder(double r, double l) {
        super(r, l);
    }

    public int compareTo(Object o) {
        if (findVolume() > ((Cylinder) o).findVolume()) {
            return 1;
        } else if (findVolume() < ((Cylinder) o).findVolume()) {
            return -1;
        } else {
            return 0;
        }
    }
}

